package com.platform.system.service.impl;

import java.util.List;

import com.platform.common.annotation.DataScope;
import com.platform.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.platform.system.mapper.ProMerchantMapper;
import com.platform.system.domain.ProMerchant;
import com.platform.system.service.IProMerchantService;

/**
 * 商家Service业务层处理
 *
 * @author platform
 * @date 2025-02-23
 */
@Service
public class ProMerchantServiceImpl implements IProMerchantService {
    @Autowired
    private ProMerchantMapper proMerchantMapper;

    /**
     * 查询商家
     *
     * @param id 商家主键
     * @return 商家
     */
    @Override
    public ProMerchant selectProMerchantById(Long id) {
        return proMerchantMapper.selectProMerchantById(id);
    }

    /**
     * 查询商家列表
     *
     * @param proMerchant 商家
     * @return 商家
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<ProMerchant> selectProMerchantList(ProMerchant proMerchant) {
        return proMerchantMapper.selectProMerchantList(proMerchant);
    }

    /**
     * 新增商家
     *
     * @param proMerchant 商家
     * @return 结果
     */
    @Override
    public int insertProMerchant(ProMerchant proMerchant) {
        proMerchant.setCreateTime(DateUtils.getNowDate());
        return proMerchantMapper.insertProMerchant(proMerchant);
    }

    /**
     * 修改商家
     *
     * @param proMerchant 商家
     * @return 结果
     */
    @Override
    public int updateProMerchant(ProMerchant proMerchant) {
        proMerchant.setUpdateTime(DateUtils.getNowDate());
        return proMerchantMapper.updateProMerchant(proMerchant);
    }

    /**
     * 批量删除商家
     *
     * @param ids 需要删除的商家主键
     * @return 结果
     */
    @Override
    public int deleteProMerchantByIds(Long[] ids) {
        return proMerchantMapper.deleteProMerchantByIds(ids);
    }

    /**
     * 删除商家信息
     *
     * @param id 商家主键
     * @return 结果
     */
    @Override
    public int deleteProMerchantById(Long id) {
        return proMerchantMapper.deleteProMerchantById(id);
    }
}
